package com.xwaf.platform.system.provider.nok;
//
//import java.util.HashMap;
//import java.util.Map;
//
//import javax.security.auth.Subject;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.platform.common.api.CommonResponse;
//import com.platform.common.api.constants.CodeUtils;
//import com.platform.common.api.constants.ShiroConstants;
//import com.platform.common.web.BaseController;
//import com.platform.system.api.entity.auth.User;
//import com.platform.system.api.service.auth.UserService;
//
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//
//@RestController
//@Api(tags = "登陸")
//@RequestMapping(value = "/auth/")
//public class LoginController extends BaseController {
//
//    @Autowired
//    private UserService userService;
//    
//	/**
//	 * 用户密码登录
//	 */
//	@RequestMapping("/login")
//	public CommonResponse login(String username, String password) {
//		UserToken token = new UserToken(LoginType.USER_PASSWORD, username, password);
////		UserToken token = new UserToken(LoginType.COMMON, username, password);
//		return shiroLogin(token);
//	}
//
//	public CommonResponse shiroLogin(UserToken token) {
//		// 登录不在该处处理，交由shiro处理
//		Subject subject = SecurityUtils.getSubject();
//		subject.login(token);
//		if (subject.isAuthenticated()) {
//			// 已经登录
//			JSON json = new JSONObject();
//			((JSONObject) json).put("token", subject.getSession().getId());
//			// 勾选了记住我
//			if (subject.isRemembered()) {
//
//			}
//			return CommonResponse.createCommonResponse(json);
//		} else {
//			return CommonResponse.createCustomCommonResponse(ShiroConstants.SHIRO_ERROR.getCode(),
//					ShiroConstants.SHIRO_ERROR.getMsg());
//		}
//	}
//
////	@RequiresPermissions("ALLOCATION_MNG_AW_MNG_LIST")
//	@RequestMapping("findList")
//	public CommonResponse findList() {
//		System.out.println(111111);
//		return CommonResponse.createCustomCommonResponse(BaseConstants.FAIL.getCode()_CODE, "查询成功!");
//	}
//	
//	@ApiOperation(value = "查看用户表详情-Test", notes = "查看用户表详情信息-Test", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
//	@GetMapping(value = "info/{userId}", produces = "application/json;charset=UTF-8")
//	public CommonResponse getInfoById(@PathVariable("userId") String userId) {
//		User user = userService.getUserOne(userId);
//		return CommonResponse.createCommonResponse(user);
//	}
//
//	/**
//	 * 未授权跳转方法
//	 * 
//	 * @return
//	 */
//	@RequestMapping("/unauth")
//	public CommonResponse unauth() {
//		SecurityUtils.getSubject().logout();
//		return CommonResponse.createCustomCommonResponse(ShiroConstants.UNAUTHO_ERROR.getCode(),
//				ShiroConstants.UNAUTHO_ERROR.getMsg());
//	}
//
//	/**
//	 * 被踢出后跳转方法
//	 * 
//	 * @return
//	 */
//	@RequestMapping("/kickout")
//	public CommonResponse kickout() {
//		return CommonResponse.createCustomCommonResponse(ShiroConstants.INVALID_TOKEN.getCode(),
//				ShiroConstants.INVALID_TOKEN.getMsg());
//	}
//
//	/**
//	 * 退出登录
//	 * 
//	 * @return
//	 */
//	@RequestMapping("/logout")
//	public CommonResponse logout() {
//		SecurityUtils.getSubject().logout();
//		return CommonResponse.createCommonResponse();
//	}
//
//	@RequestMapping(value = { "/userInfo" })
//	@ResponseBody
//	public Object user() {
//		Map<String, Object> result = new HashMap<>();
//		Subject subject = SecurityUtils.getSubject();
//		result.put("subject.getPrincipal()", subject.getPrincipal());
//		result.put("subject.getPrincipals()", subject.getPrincipals());
//		// 用户认证状态
//		Boolean isAuthenticated = subject.isAuthenticated();
//		System.out.println("用户认证状态：" + isAuthenticated);
//		result.put("RememberMe:", subject.isRemembered());
//		return result;
//	}
//
//}
